home *** CD-ROM | disk | FTP | other *** search
Wrap
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Devices.h" #include "Src.h" #include "Main.h" #include "Adv.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TfrmDevices *frmDevices; //--------------------------------------------------------------------------- __fastcall TfrmDevices::TfrmDevices(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void TfrmDevices::SetSrcOutput(void) { int CountSrc = Dev->DeviceLines->Count; for (int i = ComponentCount -1; i > 2; i--) { TsrcFrame *sf = (TsrcFrame*)this->Components[i]; delete sf; } Width = max(255, CountSrc*79+94); Left = (Screen->Width - Width)/2; if (CountSrc < 1) return; for (int i=ComponentCount-3;i<=CountSrc;i++){ //Starts a cycle TsrcFrame *sf = new TsrcFrame(this); sf->Name = AnsiString("sfr")+ AnsiString(i); sf->Parent = this; sf->Left = i*79+4; sf->Top = 48; sf->Width = 81; Dev->DeviceLines->Num = i; //sets input source to the current number sf->Label1->Caption = AnsiString(Dev->DeviceLines->Name); //Sets srcOutput Caption to the src Input device name sf->TrackBar1->Position = 65535 - Dev->DeviceLines->Volume; //sets volume value according to the movement of the slider sf->TrackBar1->Tag = i; sf->TrackBar1->OnChange = TrackBarChange; sf->TrackBar2->Position = Dev->DeviceLines->VolumeBalance; //sets balance value according to the slider position sf->TrackBar2->Tag = i; sf->TrackBar2->OnChange = BalanceTrackBarChange; sf->CheckBox1->Checked = (srcCap=="Select") ? Dev->DeviceLines->Select : !Dev->DeviceLines->Select; sf->CheckBox1->Tag = i; sf->CheckBox1->OnClick = SrcSelectChange; sf->CheckBox1->Caption = srcCap; sf->Button1->Tag = i; if (Dev->DeviceLines->AdvancedCount >= 0) sf->Button1->Visible = true; //if the current Src has any advanced options then show "Advanced" button else sf->Button1->Visible = false; //otherwise show no buttons sf->Button1->OnClick = AdvClick; } } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::DeviceClick(TObject *Sender) { Dev->Num = (int)Device->Items->Objects[Device->ItemIndex]; SetSrcOutput(); } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::FormShow(TObject *Sender) { int kDevInput = Dev->Num; //otherwise kDevOutput equals to the number of output devices on the current machine Device->Items->Clear(); for (int i=0;i<=Dev->Count;i++){ //Start cycle which checks if the current device is able to play sound Dev->Num = i; //Sets number of output device to "i" Device->Items->AddObject(Dev->Name, (TObject*)i); if (Dev->DeviceLines->Count < 1){ if (i == kDevInput) kDevInput++; } } if (kDevInput > Dev->Count) kDevInput = 0; //if the number of the alst of all the audio devices is more than number of devices which are able to playback sound Dev->Num = kDevInput; //the number of device for audio output is set to the last device 'been checked Device->ItemIndex = kDevInput; //the current device to be shown in the Combo box is set to the last device 'been checked SetSrcOutput(); } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::TrackBarChange(TObject *Sender) { TTrackBar *TrackBar = (TTrackBar*)Sender; TrackBar->Hint = AnsiString(65535-TrackBar->Position); TPoint pos; GetCursorPos(&pos); Application->ActivateHint(pos); Dev->DeviceLines->Num = TrackBar->Tag; Dev->DeviceLines->Volume = 65535-TrackBar->Position; } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::AdvClick(TObject *Sender) { TButton *Button = (TButton*)Sender; Dev->DeviceLines->Num = Button->Tag; TfrmAdv *frm = new TfrmAdv(this); frm->m_Rec = true; frm->ShowModal(); delete frm; } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::BalanceTrackBarChange(TObject *Sender) { TTrackBar *TrackBar = (TTrackBar*)Sender; Dev->DeviceLines->Num = TrackBar->Tag; Dev->DeviceLines->VolumeBalance = TrackBar->Position; } //--------------------------------------------------------------------------- void __fastcall TfrmDevices::SrcSelectChange(TObject *Sender) { if (flg) return; flg = true; TCheckBox *CheckBox = (TCheckBox*)Sender; Dev->DeviceLines->Num = CheckBox->Tag; Dev->DeviceLines->Select = (srcCap == "Select") ? CheckBox->Checked : !CheckBox->Checked;; int CountSrc = Dev->DeviceLines->Count; for (int i=3;i<=CountSrc+3;i++){ //Starts a cycle Dev->DeviceLines->Num = i-3; //sets input source to the current number TsrcFrame *sf = (TsrcFrame*)Components[i]; sf->CheckBox1->Checked = (srcCap == "Select") ? Dev->DeviceLines->Select : !Dev->DeviceLines->Select; } flg = false; } //---------------------------------------------------------------------------